Rails.application.routes.draw do
  resources :articles, except: :new do

  end

  resources :topics do
    member do
      get 'new' => 'articles#new', as: :new_article
      get 'page/:page' => 'topics#show', as: :topic_page
      put 'follow' => 'topics#follow', as: :follow
      put 'unfollow' => 'topics#unfollow', as: :unfollow
      put 'pay' => 'topics#pay', as: :pay
    end
  end

  resources :tags do
    member do
      get 'page/:page' => 'tags#show', as: :tag_page
    end
  end

  devise_for :users

  # 要改User首页默认显示的内容，则改下面这两个
  get 'user/:id' => 'users#topics', as: :user_home
  get 'user/:id/page/:page' => 'users#topics', as: :user_home_page

  get 'user/:id' => 'users#topics', as: :user_topics
  get 'user/:id/page/:page' => 'users#topics', as: :user_topics_page

  get 'user/:id/follows' => 'users#follows', as: :user_follows
  get 'user/:id/follows/page/:page' => 'users#follows', as: :user_follows_page

  get 'user/:id/paid' => 'users#paid', as: :user_paid
  get 'user/:id/paid/page/:page' => 'users#paid', as: :user_paid_page
  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  root 'topics#index'
  get 'page/:page' => 'topics#index', as: :root_page

  # post 'search' => 'topics#search', as: :search
  # get  'search/:keywords' => 'topics#search_result', as: :search_result
  # get  'search/:keywords/page/:page' => 'topics#search_result', as: :search_result_page

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end
